package com.stu.mapper;

import com.stu.pojo.ExcuseApplication;
import com.stu.vo.ExcuseApplicationVo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ExcuseApplicationMapper {

    /**
     * 添加请假申请信息
     * @param excuseApplication
     */
    @Insert("insert into excuse_application" +
            "(stu_id, excuse_days, excuse_type, excuse_begin, excuse_end,excuse_reason) " +
            "VALUES " +
            "(#{stuId},#{excuseDays},#{excuseType},#{excuseBegin},#{excuseEnd},#{excuseReason})")
    void insertExcuseApplication(ExcuseApplication excuseApplication);

    @Select("select *,excuse_application.stu_id as stuBasicId from excuse_application,stu_basic_information " +
            "where excuse_application.stu_id = #{currentId} and stu_basic_information.id = #{currentId}")
    List<ExcuseApplicationVo> selectStayApplicationWithStu(Long currentId);

    /**
     * 查询所有请假申请
     * @return
     */
    @Select("select * from excuse_application")
    List<ExcuseApplicationVo> selectStayApplicationAll();
}
